package com.rdc.qingkou.presenter;

import com.rdc.qingkou.contract.LogoutContract;
import com.rdc.qingkou.entity.Result;
import com.rdc.qingkou.model.LogoutModel;
import com.rdc.qingkou.model.imodel.OnHttpCallBack;

/**
 * Created by WaxBerry on 2017/11/20.
 */

public class LogoutPresenter implements LogoutContract.IPresenter {

    private LogoutContract.IModel mIModel;   //M层
    private LogoutContract.IView mIView;  //V层

    public LogoutPresenter(LogoutContract.IView mIView){
        this.mIView = mIView;
        mIModel = new LogoutModel();
    }

    @Override
    public void logout() {

        mIModel.logout(new OnHttpCallBack<Result>() {
            //有一个请求结果的回调,即我调用请求电影信息的方法了,M层要返回一个成功还是失败的信息给我

            @Override
            public void onSuccessful(Result result) {

                mIView.logout(result);
            }

            @Override
            public void onFaild(String errorMsg) {

                mIView.showInfo(errorMsg);   //通知V层显示错误信息
            }
        });

    }
}
